import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '申请单编码',
    align:"center",
    dataIndex: 'requisitionCode'
   },
   {
    title: '申请人',
    align:"center",
    dataIndex: 'applyUserName'
   },
   {
    title: '需求部门',
    align:"center",
    dataIndex: 'demandDepartName'
   },
   {
    title: '采购部门',
    align:"center",
    dataIndex: 'purchaseDepartName'
   },
   {
    title: '申请总金额',
    align:"center",
    dataIndex: 'totalAmount'
   },
   {
    title: '备注说明',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '审批状态',
    align:"center",
    fixed:'right',
    dataIndex: 'status',
    customRender:({text})=>{
      return render.renderDict(text,'common_audit_status')
    }
   },
   {
    title: '是否关闭',
    align:"center",
    dataIndex: 'isClose',
    customRender:({text})=>{
      return text==1?'是':'否'
    }
   },
   {
    title: '是否变更',
    align:"center",
    dataIndex: 'isChange',
    customRender:({text})=>{
      return text==1?'是':'否'
    }
   },
   {
    title: '版本号',
    align:"center",
    dataIndex: 'version'
   },
   {
    title: '寻源方式',
    align:"center",
    helpMessage:'1询比价 2招投标 3单一来源',
    dataIndex: 'sourcingType',
    customRender:({text})=>{
      return render.renderDict(text,'sourcing_type')
    }
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '申请单编码',
    field: 'requisitionCode',
    component: 'Input'
  }
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '申请单编码',
    field: 'requisitionCode',
    component: 'Input',
    componentProps:{
      disabled:true
    },
    ifShow:({values})=>{
      return !!values.requisitionCode
    }
  },
  {
    label: '申请人',
    field: 'applyUser',
    required:true,
    component: 'JSelectUser',
    componentProps: {
      multiple: '0',
      isRadioSelection:true,
      rowKey: 'id',
      labelKey: 'realname',
      maxSelectCount: 1,
    },
  },
  {
    label: '需求部门',
    field: 'demandDepart',
    required:true,
    component: 'JSelectDept',
    componentProps: {
      multiple:false,
      defaultExpandLevel:2,
      //是否开启异步加载
      sync: false,
      //是否显示复选框
      checkable: true,
      //是否显示选择按钮
      showButton: false,
      //父子节点选中状态不再关联
      checkStrictly: true,
      //选择框标题
      modalTitle: '部门选择',
      rowKey:'id',
      labelKey:'departName'
    },
  },
  {
    label: '采购部门',
    field: 'purchaseDepart',
    required:true,
    component: 'JSelectDept',
    componentProps: {
      multiple:false,
      defaultExpandLevel:2,
      //是否开启异步加载
      sync: false,
      //是否显示复选框
      checkable: true,
      //是否显示选择按钮
      showButton: false,
      //父子节点选中状态不再关联
      checkStrictly: true,
      //选择框标题
      modalTitle: '部门选择',
      rowKey:'id',
      labelKey:'departName'
    },
  },
  {
    label: '申请总金额',
    field: 'totalAmount',
    required:true,
    component: 'InputNumber',
    suffix: '元',
    componentProps:{
      style: 'width: 100%;'
    }
  },
  {
    label: '审批状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:'status'
    },
    ifShow:({values})=>{
      return !!values.id
    }
  },
  {
    label: '备注说明',
    field: 'remark',
    component: 'InputTextArea',
    componentProps:{
      allowClear: true,
      //是否展示字数
      showCount: false,
      //自适应内容高度，可设置为 true | false 或对象：{ minRows: 2, maxRows: 6 }
      autoSize: {
        //最小显示行数
        minRows: 4,
        //最大显示行数
        maxRows: 6,
      },
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  requisitionCode: {title: '申请单编码(自动生成)',order: 0,view: 'text', type: 'string',},
  applyUser: {title: '申请人',order: 1,view: 'text', type: 'string',},
  demandDepart: {title: '需求部门',order: 2,view: 'text', type: 'string',},
  purchaseDepart: {title: '采购部门',order: 3,view: 'text', type: 'string',},
  totalAmount: {title: '申请总金额',order: 4,view: 'number', type: 'number',},
  remark: {title: '备注说明',order: 5,view: 'text', type: 'string',},
  status: {title: '审批状态:0草稿 1审批中  2审批通过 3驳回',order: 6,view: 'number', type: 'number',}
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
